//package springboot.file.demo.controller;
//
//import com.alibaba.excel.EasyExcel;
//import com.alibaba.excel.support.ExcelTypeEnum;
//import lombok.SneakyThrows;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RestController;
//import springboot.file.demo.data.MemberData;
//import springboot.file.demo.pojo.Member;
//import springboot.file.demo.util.TimeUtils;
//
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.io.UnsupportedEncodingException;
//import java.net.URLEncoder;
//import java.util.Date;
//import java.util.List;
//
///**
// * @Author: jxm
// * @Description:
// * @Date: 2022/10/21 15:22
// * @Version: 1.0
// */
//@RestController
//@RequestMapping("/excel")
//public class ExportExcelController {
//
//    @SneakyThrows(IOException.class)
////    @ApiOperation(value = "导出会员列表Excel")
//    @RequestMapping(value = "/exportMemberList", method = RequestMethod.GET)
//    public void exportMemberList(HttpServletResponse response) {
//        setExcelRespProp(response, "黔系列电商销售数据统计-"+ TimeUtils.getCurrDateTime());
////        List<Member> memberList = LocalJsonUtil.getListFromJson("json/members.json", Member.class);
//        List<Member> memberList = MemberData.getList();
//        EasyExcel.write(response.getOutputStream())
//                .head(Member.class)
//                .excelType(ExcelTypeEnum.XLSX)
//                .sheet("黔系列电商销售数据统计")
//                .doWrite(memberList);
//    }
//
//    /**
//     * 设置excel下载响应头属性
//     */
//    @GetMapping("/setExcelRespProp")
//    private void setExcelRespProp(HttpServletResponse response, String rawFileName) throws UnsupportedEncodingException {
//        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
//        response.setCharacterEncoding("utf-8");
//        String fileName = URLEncoder.encode(rawFileName, "UTF-8").replaceAll("\\+", "%20");
//        response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
//    }
//}
